GBML manual / Drawing

show_collision

Draws a 1-pixel-thick red outline around this instance's own collision mask (the real box pos_free/move_slide/etc test against, not its sprite's bounds) when on is true - draws nothing when it is false or this is never called.

Works differently on Game Boy - The Game Boy draws no collision outlines, so this does nothing there.

Works differently on Game Boy Color - The Game Boy Color draws no collision outlines, so this does nothing there.

Sega Genesis: not built yet

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

show_collision(on)

Arguments

NameType
onbool

Returns

Nothing.

Description

Draws a 1-pixel-thick red outline around this instance's own collision mask - the real box pos_free/move_slide/etc actually test against, not this instance's sprite bounds - when on is true. Draws nothing when on is false, and draws nothing at all if this is never called.

This is a plain function call, not a switch you flip once and forget: nothing is stored on the instance, so call it every frame (typically from a Draw event) for the box to keep showing.

Example

var debug_mode = true;
show_collision(debug_mode);

Shows this instance's own collision box exactly while debug_mode is true - written as a plain call with a computed condition, not an if, since show_collision already does nothing when on is false. A real project would read this from somewhere project-wide (a global toggled by a debug key), not re-declare it every frame the way this self-contained example does.

Cost

A plain immediate-mode draw call, cached like draw_rect (its own "Cost" section applies - up to 4 sprites, up to 2 shared affine matrices). Calling it with on false, or not calling it at all, touches the draw cache not once - the cheapest possible "off."

Always drawn on hardware layer 0 (the frontmost), at the frontmost depth - never this instance's own bg_priority/depth. A shrouded room's own darkness sits at layer 0 too, so a debug box that inherited this instance's usual layer (often 3, behind the shroud) would go dark along with the room it is trying to show collision in - the one place show_collision deliberately ignores your own layering, so the box stays visible everywhere.

There is no stored "show collision" flag anywhere on gbml::instance - see show_collision_all for the one project-wide switch this whole feature does expose, and why a per-instance one was not added.

On the GBA

A plain immediate-mode draw call like draw_rect (its own cost note applies), evaluated fresh every time it runs - call it every frame from a Draw event, typically show_collision(debug_mode) with your own project-wide debug flag, so the box tracks the instance and disappears the instant you stop asking for it. Always drawn on hardware layer 0 at the frontmost depth, never this instance's own bg_priority/depth - a shrouded room's own darkness sits at layer 0 too (gbml::instance::bg_priority's own note), and a debug box that went dark along with the room it is showing collision in would defeat the point.

See also: show_collision_alldraw_rectmask_w